package com.taomus.mytools.simplec.common;

import java.util.HashMap;
import java.util.Map;

/**
 * 
 * @author user
 *
 */
public class Word extends Token {
	
	public final static Token TK_MOV = new Token(WordEnum.MOV),
			TK_EQ = new Token(WordEnum.EQ),
			TK_NE = new Token(WordEnum.NE),
			TK_GT = new Token(WordEnum.GT),
			TK_GE = new Token(WordEnum.GE),
			TK_LT = new Token(WordEnum.LT),
			TK_LE = new Token(WordEnum.LE),
	       TK_FUNCB = new Token(WordEnum.FUNCL),
	       TK_FUNCE = new Token(WordEnum.FUNCR),
	       TK_FUNC = new Token(WordEnum.FUNC),
	       TK_FAGRS = new Token(WordEnum.FAGRS),
	       TK_FRAGRS = new Token(WordEnum.FRAGRS),
	       TK_FCALL = new Token(WordEnum.FCALL),
		   TK_SPLIT = new Token(WordEnum.SPLIT),
		   TK_LP = new Token(WordEnum.LP),
		   TK_RP = new Token(WordEnum.RP)
		   ;
	public final static Token TK_ADD = new Token(WordEnum.ADD),
								  TK_SUB = new Token(WordEnum.SUB),
								  TK_MUL = new Token(WordEnum.MUL),
								  TK_DIV = new Token(WordEnum.DIV),
								  TK_MOD = new Token(WordEnum.MOD);
	//KeyWord
	public final static Token TK_EOF=new Token(WordEnum.EOF),
			TK_ROW = new Token(WordEnum.ROW),
			KW_INT = new Token(WordEnum._INT),
			KW_INT32 = new Token(WordEnum._INT32),
			KW_INT64 = new Token(WordEnum._INT64),
			KW_INT16 = new Token(WordEnum._INT16),
			KW_DOUBLE = new Token(WordEnum._DOUBLE),
			KW_FLOAT = new Token(WordEnum._FLOAT),
			KW_CHAR = new Token(WordEnum._CHAR),
			KW_STRING = new Token(WordEnum._STRING),
			KW_IF = new Token(WordEnum.IF),
			KW_IFEND = new Token(WordEnum.IFEND),
			KW_ELSE = new Token(WordEnum.IFELSE),
			KW_GOTO = new Token(WordEnum.GOTO),
			IR_IFGT = new Token(WordEnum.IFGT),
			IR_IFLT = new Token(WordEnum.IFLT),
			IR_IFNE = new Token(WordEnum.IFNE),
			IR_IFEQ = new Token(WordEnum.IFEQ),
			IR_BOOL = new Token(WordEnum._BOOL),
			IR_PRINT = new Token(WordEnum.PRINT),
			TK_ERROR = new Token(WordEnum.ERR)
			;
	private static Map<String,Token> keywordMap  = null;
	public static Token getKeyWordToken(String keyword){
		if(keywordMap == null){
			keywordMap = new HashMap<>();
			keywordMap.put("func", new Token(WordEnum.FUNC));
			keywordMap.put("print", new Token(WordEnum.PRINT));
		}
		if(keywordMap.containsKey(keyword)){
			return keywordMap.get(keyword);
		}else{
			return null;
		}
	}
	public Word(WordEnum code, String symbol) {
		super(code, symbol);
	}
}
